//引入请求接口
import {reqTypeNav,reqBanner,reqFloor} from '@/api/'
export default {
    state: () => ({
        types:[],
        banners:[],
        floors:[]
    }),
    mutations:{
        GETTYPES(state,data){
            state.types=data
        },
        GETBANNER(state,data){
            state.banners=data
        },
        GETFLOOR(state,data){
            state.floors=data
        }
    },
    actions: {
        async getTypes(context){
            try{
                //请求分类数据
                const types=await reqTypeNav()
                if(types.code===200){
                    context.commit('GETTYPES',types.data)
                }
            }
            catch(err){

            }
        },
       async getBanner(context){
            try{
                //请求轮播数据
                const banners=await reqBanner()
                if(banners.code===200){
                    context.commit('GETBANNER',banners.data)
                }
            }
            catch(err){

            }
        },
       async getFloor(context){
            try{
                //请求楼层数据
                const floor=await reqFloor()
                if(floor.code===200){
                    context.commit('GETFLOOR',floor.data)
                }
            }
            catch(err){

            }
        } 
    }
}